//
//  SSCRequest+API.m
//  SSC
//
//  Created by 红沙尘 on 17/6/6.
//  Copyright © 2017年 红沙尘. All rights reserved.
//

#import "SSCRequest+API.h"

@implementation SSCRequest (API)

#pragma mark - 3.29 

+ (void)sumAgentListSuccess:(void (^)(NSDictionary *responseObject))success
                       fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/sumAgentList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.28､解绑银行卡/cardUnbind.do

+ (void)jiebangWithId:(NSString *)cardId
              success:(void (^)(NSDictionary *responseObject))success
                 fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"id":cardId};
    
    [self requestWithApi:SSC_HOST@"/cardUnbind.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.27､版本更新首页通知公告(api/appUpdate.do)

+ (void)appUpdateWithSystem:(NSString *)sys
                    success:(void (^)(NSDictionary *responseObject))success
                       fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"sys":sys};
    
    [self requestWithApi:SSC_HOST@"/appUpdate.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.26､代理下级用户投注和返利情况 (api/agentDayinfoList.do)

+ (void)agentDayinfoListStartdt:(NSString *)startdt
                          enddt:(NSString *)enddt
                           page:(NSInteger)page
                        success:(void (^)(NSDictionary *responseObject))success
                           fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10"};
    
    [self requestWithApi:SSC_HOST@"/agentDayinfoList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.25､用户银行卡记录(api/cardList.do) yes

+ (void)cardListSuccess:(void (^)(NSDictionary *responseObject))success
                   fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/cardList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.24､用户添加银行卡(api/bindCard.do) yes
/*
 字段	类型	说明	备注
 banks	String	总行名称，	总行名称，
 bankname	String	支行名称	支行名称
 bankcard	String	银行卡号	银行卡号
 username		总行名称，	银行帐号姓名
 */

+ (void)bindCardWithBanks:(NSString *)banks
                 bankname:(NSString *)bankname
                 bankcard:(NSString *)bankcard
                 username:(NSString *)username
                  success:(void (^)(NSDictionary *responseObject))success
                     fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"banks":banks,
                             @"bankname":bankname,
                             @"bankcard":bankcard,
                             @"username":username};
    
    [self requestWithApi:SSC_HOST@"/bindCard.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.23､追号投注记录(api/userPlanBettList.do) yes
/*
 字段	类型	说明	备注
 page	String	页码	默认为1
 size	String	每页数量	默认为10
 startdt	String	查询开始日期	默认空
 enddt	String	查询结束日期	默认空

 */
+ (void)userPlanBettListStartdt:(NSString *)startdt
                          enddt:(NSString *)enddt
                           page:(NSInteger)page
                          otype:(CaipiaoType)otype
                        success:(void (^)(NSDictionary *responseObject))success
                           fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10",
                             @"otype":[NSString stringWithFormat:@"%d",(int)otype]};
    
    [self requestWithApi:SSC_HOST@"/userPlanBettList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.22､追号投注(api/planBetting.do) no
/*
 字段	类型	说明	备注
 issuenum	String	追加期号数
 isstop	String	是否中奖停止追	1是，0不是
 amount	String	投注总金额	Double：0.00
 issue	String	追开始期号
 numbers	String	每期投注数量
 
 订单下内容列表:list
 playid	String	投注类型id
 amount	String	此注金额
 code	String	投注号
 doubles	String	倍数
 numbers	String	投注数
 playname	String	投注类型名称
 place	String	投注位置	一星时有位置，1个位，2十位，3百位，四千位，5万位

 */
+ (void)planBettingWithIssuenum:(NSString *)issuenum
                         isstop:(NSString *)isstop
                         amount:(NSString *)amount
                          issue:(NSString *)issue
                        numbers:(NSString *)numbers
                          otype:(CaipiaoType)otype
                           list:(NSMutableArray *)list
                        success:(void (^)(NSDictionary *responseObject))success
                           fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"issuenum":issuenum,
                             @"isstop":isstop,
                             @"amount":amount,
                             @"issue":issue,
                             @"numbers":numbers,
                             @"otype":[NSString stringWithFormat:@"%d",(int)otype],
                             @"list":list};
    
    [self requestWithApi:SSC_HOST@"/planBetting.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.21､获取当前未开始期号(api/queryFutrueListIssue.do) no

+ (void)queryFutrueListIssueWithType:(CaipiaoType)otype
                             success:(void (^)(NSDictionary *responseObject))success
                               fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"otype":[NSString stringWithFormat:@"%d",(int)otype]};
    
    [self requestWithApi:SSC_HOST@"/queryFutrueListIssue.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.20､获取投注玩法说明(api/queryPlayMenthodList.do) 客户端写死不需要接口

+ (void)queryPlayMenthodListSuccess:(void (^)(NSDictionary *responseObject))success
                               fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/queryPlayMenthodList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.19､获取当前可投注期号(api/queryCurrentIssue.do) yes

+ (void)queryCurrentIssueWithType:(CaipiaoType)otype
                          success:(void (^)(NSDictionary *responseObject))success
                            fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"otype":[NSString stringWithFormat:@"%d",(int)otype]};
    
    [self requestWithApi:SSC_HOST@"/queryCurrentIssue.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.18用户忘记密码(api/userforgetpass.do) yes
/*
 字段	类型	说明	备注
 username	String	用户名	必选项，
 email	String	邮箱号	必选项
 content	String		必选项

 */
+ (void)userforgetpassWithUsername:(NSString *)username
                             email:(NSString *)email
                           content:(NSString *)content
                           success:(void (^)(NSDictionary *responseObject))success
                              fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"username":username,
                             @"email":email,
                             @"content":content};
    
    [self requestWithApi:SSC_HOST@"/userforgetpass.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}
#pragma mark - 3.17、投注截止时间(api/bettEndtime.do) yes
/*
 */

+ (void)bettEndtimeSuccess:(void (^)(NSDictionary *responseObject))success
                      fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/bettEndtime.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.16､投注记录查询(api/userOrderList.do) yes
/*
 字段	类型	说明	备注
 page	String	页码	默认为1
 size	String	每页数量	默认为10
 startdt	String	查询开始日期	默认空
 enddt	String	查询结束日期	默认空

 */

+ (void)userOrderListStartdt:(NSString *)startdt
                       enddt:(NSString *)enddt
                        page:(NSInteger)page
                        type:(CaipiaoType)otype
                     success:(void (^)(NSDictionary *responseObject))success
                        fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10",
                             @"otype":[NSString stringWithFormat:@"%d",(int)otype]};
    
    [self requestWithApi:SSC_HOST@"/userOrderList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.15､撤销订单/投注(api/undoBetting.do) 客户端暂时没有撤销功能
/*
 字段	类型	说明	备注
 id	String	订单id	必选项，
 itemid	String	订单详情id	订单下投注id，如果这个是空的则撤消整个订单，如果有值则撤测订单下某个投注
 */

+ (void)undoBettingWithId:(NSString *)orderId
                   itemid:(NSString *)itemid
                  success:(void (^)(NSDictionary *responseObject))success
                     fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"id":orderId,
                             @"itemid":itemid};
    
    [self requestWithApi:SSC_HOST@"/undoBetting.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}
#pragma mark - 3.14､投注(api/betting.do) yes
/*
 字段	类型	说明	备注
 amount	String	投注总金额	Double：0.00
 issue	String	期号
 numbers	String	总投注数量
 list
 playid	String	投注类型id
 amount	String	此注金额
 code	String	投注号
 doubles	String	倍数
 numbers	String	投注数
 playname	String	投注类型名称
 place	String	投注位置	一星时有位置，1个位，2十位，3百位，四千位，5万位
 otype	String	彩票类型	0是时时彩，1是分分彩
 */

+ (void)bettingWithAmount:(NSString *)amount
                    issue:(NSString *)issue
                  numbers:(NSString *)numbers
                    otype:(CaipiaoType)otype
                     list:(NSMutableArray *)list
                  success:(void (^)(NSDictionary *responseObject))success
                     fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"amount":amount,
                             @"issue":issue,
                             @"numbers":numbers,
                             @"otype":[NSString stringWithFormat:@"%d",(int)otype],
                             @"list":list};
    
    [self requestWithApi:SSC_HOST@"/betting.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}
#pragma mark - 3.13用户提现(api/applyAmount.do) yes
/*
 字段	类型	说明	备注
 amount	String	提现金额	Double：0.00
 type	String	提现金额转入类型	0是微信
 password	String	资金密码
 */
+ (void)applyAmount:(NSString *)amount
               type:(NSString *)type
           password:(NSString *)password
             bankid:(NSString *)bankid
            success:(void (^)(NSDictionary *responseObject))success
               fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"amount":amount,
                             @"type":type,
                             @"password":password,
                             @"bankid":bankid};
    
    [self requestWithApi:SSC_HOST@"/applyAmount.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.12、用户中奖记录查询(api/orderWinList.do) yes

+ (void)orderWinListStartdt:(NSString *)startdt
                      enddt:(NSString *)enddt
                       page:(NSInteger)page
                    success:(void (^)(NSDictionary *responseObject))success
                       fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10",
                             @"otype":[NSString stringWithFormat:@"%d",(int)CaipiaoTypeUnknow]};
    
    [self requestWithApi:SSC_HOST@"/orderWinList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.11､用户提现记录查询(api/applyAmountLogs.do) yes

+ (void)applyAmountLogsStartdt:(NSString *)startdt
                         enddt:(NSString *)enddt
                          page:(NSInteger)page
                       success:(void (^)(NSDictionary *responseObject))success
                          fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10"};
    
    [self requestWithApi:SSC_HOST@"/applyAmountLogs.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.10用户充值记录查询(api/rechargeAmountLogs.do) yes
/*
 上行
 字段	类型	说明	备注
 page	String	页码	默认为1
 size	String	每页数量	默认为10
 startdt	String	查询开始日期	默认空
 enddt	String	查询结束日期	默认空
 */
+ (void)rechargeAmountLogsStartdt:(NSString *)startdt
                            enddt:(NSString *)enddt
                             page:(NSInteger)page
                          success:(void (^)(NSDictionary *responseObject))success
                             fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"startdt":startdt,
                             @"enddt":enddt,
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10"};
    
    [self requestWithApi:SSC_HOST@"/rechargeAmountLogs.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}
#pragma mark - 3.9､用户充值(api/rechargeAmount.do) yes
/*
 字段	类型	说明	备注
 amount	String	充值金额	为double二位小数的数据
 type	String	充值类型	默认为0微信充值，
 nums	String	第三方充值流水号
 status	String	状态，第三方返回的	1是充值成功，0是失败

 */
+ (void)rechargeAmount:(NSString *)amount
                  type:(NSString *)type
               success:(void (^)(NSDictionary *responseObject))success
                  fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"amount":[NSString safeString:amount],
                             @"type":[NSString safeString:type],
                             @"status":@"0"};
    
    [self requestWithApi:SSC_HOST@"/rechargeAmount.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.8､往期开奖记录查询(api/lotteryHistoryList.do) yes
/*
 searchday	String	必须是：2017-06-08格式	如果日期为空时，后台会默认当前日期,如果传的不是日期，后台也会默认为当前日期
 page	String	页码	默认为1
 size	String	每页数量	默认为10
 */
+ (void)lotteryHistoryListAtDate:(NSString *)date
                            page:(NSInteger)page
                            type:(CaipiaoType)otype
                         success:(void (^)(NSDictionary *responseObject))success
                            fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"searchday":[NSString safeString:date],
                             @"page":[NSString stringWithFormat:@"%d",(int)page],
                             @"size":@"10",
                             @"otype":[NSString stringWithFormat:@"%d",(int)otype]};
    
    [self requestWithApi:SSC_HOST@"/lotteryHistoryList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.7首页轮播图 yes

+ (void)bannerListSuccess:(void (^)(NSDictionary *responseObject))success
                     fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/queryIndexPicList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.6､首页通知公告(api/queryNoticeList.do) yes

+ (void)queryNoticeListSuccess:(void (^)(NSDictionary *responseObject))success
                          fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/queryNoticeList.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.5､用户中心余额(api/queryUserAmount.do) yes

+ (void)queryUserAmountSuccess:(void (^)(NSDictionary *responseObject))success
                          fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{};
    
    [self requestWithApi:SSC_HOST@"/queryUserAmount.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.4､修改交易密码 (api/updateAmountpassword.do) yes

+ (void)updateAmountpassword:(NSString *)old
                    password:(NSString *)password
                truepassword:(NSString *)truepassword
                     success:(void (^)(NSDictionary *responseObject))success
                        fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"oldpassword":[NSString safeString:old],
                             @"password":[NSString safeString:password],
                             @"truepassword":[NSString safeString:truepassword]};
    
    [self requestWithApi:SSC_HOST@"/updateAmountpassword.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}


#pragma mark - 3.3､修改登录密码(api/updatepassword.do) yes

+(void)updatepassword:(NSString *)old
             password:(NSString *)password
         truepassword:(NSString *)truepassword
              success:(void (^)(NSDictionary *responseObject))success
                 fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"oldpassword":[NSString safeString:old],
                             @"password":[NSString safeString:password],
                             @"truepassword":[NSString safeString:truepassword]};
    
    [self requestWithApi:SSC_HOST@"/updatepassword.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}

#pragma mark - 3.2开户 yes

+ (void)regWithUsername:(NSString *)username
               password:(NSString *)password
                success:(void (^)(NSDictionary *responseObject))success
                   fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"Username":[NSString safeString:username],
                             @"password":[NSString safeString:password]};
    
    [self requestWithApi:SSC_HOST@"/reg.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
                    fail:^(NSError *error)
     {
         fail(error);
     }];
}
#pragma mark - 3.1登录 yes

+ (void)loginWithAccount:(NSString *)account
                password:(NSString *)password
                 success:(void (^)(NSDictionary *responseObject))success
                    fail:(void (^)(NSError *error))fail {
    
    NSDictionary *params = @{@"Username":[NSString safeString:account],
                             @"password":[NSString safeString:password]};
    
    [self requestWithApi:SSC_HOST@"/login.do"
                   param:params
             thenSuccess:^(NSDictionary *responseObject)
     {
         success(responseObject);
     }
    fail:^(NSError *error)
     {
         fail(error);
     }];
}


@end
